package org.link.web;

import java.io.File;
import java.io.IOException;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartFile;

/**
 * 
 * project_name:springdemo2
 * package_name:org.link.web
 * file_name:UpLoadControllar.java
 * @author Link
 * create_date:2015年11月18日 下午5:03:26
 * modified_date:
 * description:文件上传控制器
 *
 */
@Controller
public class UpLoadControllar {

	@RequestMapping(value="/index",method=RequestMethod.GET)
	public String index(){
		return "upload";
	}
	
	@RequestMapping(value="/upload",method = RequestMethod.POST)
	public String upload(MultipartFile file) throws IllegalStateException, IOException{
		System.out.println(file.getName());
		System.out.println(file.getOriginalFilename());
		System.out.println(file.getSize());
		System.out.println(file.getContentType());
		file.transferTo(new File("F:/"+file.getOriginalFilename()));//将上传的文件保存至对应的位置
		return "upload";
	}
	
}
